<?php

namespace Ignus\View\Node;

use Ignus\View\Node;
use Ignus\View\Compiler;
use Ignus\View\NodeInterface;
use Ignus\View\NodeOutputInterface;

class BlockReference extends Node implements NodeOutputInterface
{
    public function __construct($name, $lineno, $tag = null)
    {
        parent::__construct(array(), array('name' => $name), $lineno, $tag);
    }

    public function compile(Compiler $compiler)
    {
        $compiler
            ->addDebugInfo($this)
            ->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name')));
    }
}
